<template>
	<view>
		<u-picker :show="show1" :columns="columns" @cancel="show1=false" @confirm="confirm" keyName="name"></u-picker>
		<view class="" style="margin: 30rpx;font-weight: 600;font-size: 46rpx;">
			待发货
		</view>
		<view class="" style="margin: 30rpx;">
			请尽快进行发货，填写快递单号
		</view>
		<view class="box">
			<view class="line">
				<view class="" style="color: #616161;margin-right: 60rpx;">
					快递公司
				</view>
				<!-- <u--input placeholder="请输入快递公司" border="none" fontSize="28rpx" v-model="express_name"></u--input> -->
				<view class="flex" style="flex: 1;" @click="show1=true">
					<view class="" style="flex: 1;">
						<u--input placeholder="请选择快递公司" border="none" fontSize="28rpx" readonly v-model="express_name">
						</u--input>
					</view>
					<u-icon name="arrow-down"></u-icon>
				</view>
			</view>
			<view class="line" style="border-bottom: none;">
				<view class="" style="color: #616161;margin-right: 60rpx;">
					快递单号
				</view>
				<u--input placeholder="请输入快递单号" border="none" fontSize="28rpx" v-model="express_no"></u--input>
			</view>
		</view>
		<view class="box">
			<view class="line">
				<view class="" style="color: #616161;margin-right: 60rpx;">
					订单号
				</view>
				<view class="" style="text-align: right;flex: 1;">
					{{info.order_no || '---'}}
				</view>
			</view>
			<view class="line">
				<view class="" style="color: #616161;margin-right: 60rpx;">
					姓名
				</view>
				<view class="" style="text-align: right;flex: 1;">
					{{info.address.name || '---'}}
				</view>
			</view>
			<view class="line">
				<view class="" style="color: #616161;margin-right: 60rpx;">
					手机号
				</view>
				<view class="" style="text-align: right;flex: 1;">
					{{info.address.mobile || '---'}}
				</view>
			</view>
			<view class="line" style="border-bottom: 0;">
				<view class="" style="color: #616161;margin-right: 60rpx;">
					地址
				</view>
				<view class="" style="text-align: right;flex: 1;">
					{{info.address.address || '---'}}
				</view>
			</view>
		</view>

		<view class="btn" @click="send" v-if="show">
			确认发货
		</view>
		<view class="btn1" v-else>
			已发货
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				show1: false,
				columns: [
					['中国', '美国', '日本']
				],
				info: {

				},
				express_name: "",
				express_no: "",
				chooseList: []

			}
		},
		async onLoad(opt) {
			await uni.request({
				url: '/index/orderDetail',
				data: {
					id: opt.id
				},
				header: {
					isAdmin: true,
					token: uni.getStorageSync("shop_login_token")
				},
				method: "GET",
				success: res => {
					console.log(res)
					this.info = res.data;

				}
			});
			await uni.request({
				url: '/index/getexpressionlist',
				header: {
					isAdmin: true,
					token: uni.getStorageSync("shop_login_token")
				},
				method: "GET",
				success: res => {
					this.columns = [res.data];
				}
			});
		},
		methods: {
			confirm(e) {
				console.log(e)
				this.express_name = e.value[0].name;
				this.show1 = false;
			},
			async send() {
				let that = this;
				if (!this.express_name) {
					uni.showToast({
						icon: "none",
						title: "请输入快递公司"
					})
					return
				}
				if (!this.express_no) {
					uni.showToast({
						icon: "none",
						title: "请输入快递单号"
					})
					return
				}
				uni.showLoading({
					mask: true
				})
				await uni.request({
					url: '/index/express',
					data: {
						id: this.info.id,
						express_name: this.express_name,
						express_no: this.express_no,
					},
					header: {
						isAdmin: true,
						token: uni.getStorageSync("shop_login_token")
					},
					method: "POST",
					success: res => {
						console.log(res)
						uni.showToast({
							icon: "none",
							title: "成功发货"
						})
						uni.hideLoading()
						that.show = false
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.btn {
		position: fixed;
		bottom: 80rpx;
		width: calc(100vw - 120rpx);
		left: 60rpx;
		background-color: black;
		color: white;
		text-align: center;
		padding: 26rpx 0;
		border-radius: 100px;
	}

	.btn1 {
		position: fixed;
		bottom: 80rpx;
		width: calc(100vw - 120rpx);
		left: 60rpx;
		background-color: #e1e1e1;
		color: grey;
		text-align: center;
		padding: 26rpx 0;
		border-radius: 100px;
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.box {
		margin: 30rpx;
		background-color: white;
		border-radius: 20rpx;
		padding: 0 30rpx;

		.line {
			display: flex;
			align-items: center;
			padding: 30rpx;
			border-bottom: 1rpx solid #E9E8E8;
		}
	}
</style>